package com.common.sub.util;

import java.util.ArrayList;
import java.util.List;

import com.alibaba.fastjson.JSON;
import com.casicloud.manage.model.UserRole;

public class UserRoleList {
	
	public UserRoleList(List<UserRole> urlist){
		
		
		authoritylist = new ArrayList<Integer>();
		menulist = new ArrayList<Integer>();
		for(UserRole urr:urlist){
			
			if(urr!=null&&urr.getRole()!=null){
				
				String permissions = urr.getRole().getPermissions();
				if(permissions!=null){
					List<Integer> plist = JSON.parseArray(permissions, Integer.class);
					for(Integer p:plist){
						
						if(p>0){
							if(!menulist.contains(p))
							menulist.add(p);
						}else{
							p = -p;
							if(!authoritylist.contains(p))
								authoritylist.add(p);
						}
						
					}
				}
				
			}
			
		}
	}
	

	private List<Integer> menulist;
	private List<Integer> authoritylist;

	public List<Integer> getMenulist() {
		return menulist;
	}

	public void setMenulist(List<Integer> menulist) {
		this.menulist = menulist;
	}

	public List<Integer> getAuthoritylist() {
		return authoritylist;
	}

	public void setAuthoritylist(List<Integer> authoritylist) {
		this.authoritylist = authoritylist;
	}
	
	
	

}
